//引入请求函数
import request from "@/utils/request.ts";
import { requestHttp } from "@/utils/request.ts";

//引入类型约束

/**
 * 用户购物车数据相关请求api
 */


//请求添加商品到购物车
export const reqAddUserCart = (cartInfo:any) => {
    return requestHttp<any>({
        url:"/reception/user/cart",
        method:"post",
        data:{
            cartUserId:cartInfo.cartUserId,
            cartCommodityId:cartInfo.cartCommodityId,
            cartCommodityCount:cartInfo.cartCommodityCount,
            cartCommodityAttr:cartInfo.cartCommodityAttr,
            cartCommodityStandardId:cartInfo.cartCommodityStandardId,
            cartSelected:false
        }
    })
}

//根据用户id请求用户所有的购物车数据
export const reqUserCartList = (userId:number) => {
    return requestHttp<any>({
        url:"/reception/user/cart",
        method:"get",
        params:{
            userId:userId
        }
    })
}

//修改用户的某条购物车数据
export const reqUpdateUserCart = (cartInfo:any) => {
    return requestHttp<any>({
        url:"/reception/user/cart",
        method:"put",
        data:cartInfo
    })
}

//修改用户购物车的选中状态(支持单条、批量修改)
export const reqUpdateUserCartSelectedBatch = (cartIds:number[],cartState:boolean) => {
    return requestHttp<any>({
        url:"/reception/user/cart/batch",
        method:"put",
        data:{
            cartIds:cartIds,
            cartState:cartState
        }
    })
}

//删除用户购物车的商品(支持单条、批量删除)
export const reqDeleteUserCartBatch = (cartIds:number[]) => {
    return requestHttp<any>({
        url:"/reception/user/cart/batch",
        method:"delete",
        data:cartIds
    })
}